#pragma once

#ifndef MAIN_SCENE_H
#define MAIN_SCENE_H

#include <QtGui/QGraphicsView>
#include <QtGui/QGraphicsScene>
#include "connection.h"
#include "railway.h"

enum drawtype {unset = 0, station, connection, train};

class CMainScene :
	public QGraphicsScene
{
private:	
	CRailway			  m_railway;
	QGraphicsView		 *m_view;
	QPointF				  m_begin;
	QPointF				  m_finish;
	QGraphicsLineItem    *m_connection;
protected:
	drawtype			  m_drawtype;

public:
	CMainScene();
	~CMainScene(void);
	void setDrawType(drawtype);
	drawtype getDrawType();
protected:
	void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent);
    void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent);
    void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent);
private:
	void addStation(const QPointF &);
	void addConnection(const QPointF &, bool);
	QGraphicsItem * getItem(int, const QPointF &);
};

#endif //MAIN_SCENE_H